#include "DevUtils.h"
#include "DevUtilsIos.h"

DevUtils* DevUtils::s_sharedDevUtils=NULL;
DevUtils* DevUtils::sharedDevUtils()
{
    if (s_sharedDevUtils == NULL)
    {
        s_sharedDevUtils = new DevUtilsIos();
    }
 
    return s_sharedDevUtils;
}


void DevUtils::showBarAd(){
    
}
 
void DevUtils::showBigAd(){
    
}


DevUtils::DevUtils()
:m_minWidth(0)
,m_minHeight(0){
    
}

void DevUtils::onBarShowed(){
    
}


void DevUtils::onBigAdClose(){
    
}

void DevUtils::setMinSize(int minWidth,int minHeight){
    m_minWidth=minWidth;
    m_minHeight=minHeight;
    initScreen();
}

 
void DevUtils::initScreen(){
    int minWidth=m_minWidth;
    int minHeight=m_minHeight;
    
    int adWidth=m_adWidth;
    int adHeight=m_adHeight;
    float frameWidth=  CCEGLView::sharedOpenGLView()->getFrameSize().width;
    float frameHeight= CCEGLView::sharedOpenGLView()->getFrameSize().height;
    
    
    float scaleH,scaleW;
    float gameHeight,gameWidth;
    
    
    
    gameHeight=minHeight;
    scaleH= (float)frameHeight/gameHeight;
    gameWidth = (float)(frameWidth/scaleH);
    
    if(gameWidth<minWidth){
        gameWidth=minWidth;
        scaleW=(float)frameWidth/gameWidth;
        gameHeight = (float)(frameHeight/scaleW);
    }
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(gameWidth , gameHeight , kResolutionShowAll,adWidth,adHeight);
}
void DevUtils::setAdSize(int adWidth,int adHeight){
    m_adWidth=adWidth;
    m_adHeight=adHeight;
    initScreen();
}